package client.screen;

import javax.microedition.lcdui.*;

import client.MorcMIDlet;

public class FriendsScreen extends List implements CommandListener {
	private MorcMIDlet midlet;
	private Command back, sendScrap;
	private String selectedFriend;

	public FriendsScreen(MorcMIDlet midlet, String title, int listType) {
		super(title, listType);
		
		this.midlet = midlet;
		this.back = new Command("Voltar", Command.BACK, 0);
		this.sendScrap = new Command("Enviar recado", Command.ITEM, 0);

		this.addCommand(this.back);
		this.addCommand(this.sendScrap);
	}

	public void commandAction(Command c, Displayable d) {
		if (c == back) {
			this.midlet.setScreen(MorcMIDlet.SCREEN_MAIN);
		}
		else if (c == sendScrap) {
			this.selectedFriend = this.getString(this.getSelectedIndex());
			this.midlet.setScreen(MorcMIDlet.SCREEN_SCRAP);
			this.midlet.setRecipient(this.selectedFriend);
		}
	}

}
